module PaginatorHelper
  include ActionController::Pagination
  ##
  # This method makes an collection "paginateable"
  # @param collection is the collection which should be paginateable
  # @param options is a hash which mey contain a value for :per_page and :page.
  #        The default-value for the hash-keys are 10 and 1
	def paginate_collection(collection, options = {})
    default_options = { :per_page => 10, :page => 1 }
    options = default_options.merge options
    
    pages = Paginator.new self, collection.size, options[:per_page], 
													options[:page]
    first = pages.current.offset
    last = [first + options[:per_page], collection.size].min
    slice = collection[first...last]
    return [pages, slice]
  end
end
